﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.DynamicData;

namespace NotAClue.Web.DynamicData
{
    /// <summary>
    /// Class to contains information about cascading drop-down lists
    /// </summary>
    public class HierachicalControlList
    {
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            var parentColumn = ParentColumn != null ? ParentColumn.Name : "null";
            return String.Format("{0}.{1}", Column.Name, parentColumn);
            //return this.Column.Name;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="HierachicalListControl"/> class.
        /// </summary>
        /// <param name="column">This column.</param>
        /// <param name="parentColumn">This column's parent column.</param>
        public HierachicalControlList(ListControl listControl)
        {
            ListControl = listControl;
        }

        /// <summary>
        /// Gets or sets the filter column.
        /// </summary>
        /// <value>The column.</value>
        public MetaForeignKeyColumn Column { get; set; }

        /// <summary>
        /// Gets or sets the filter column's parent column.
        /// </summary>
        /// <value>The parent column.</value>
        public MetaForeignKeyColumn ParentColumn { get; set; }

        /// <summary>
        /// Gets or sets the list control.
        /// </summary>
        /// <value>The list control.</value>
        public ListControl ListControl { get; set; }
    }
}
